package controller

import (
	"data-system/common"
	"data-system/excel"
	"data-system/models"
	"fmt"
	"log"

	"github.com/gin-gonic/gin"
)

func ResolveConflict(c *gin.Context) {
	req := struct {
		NodeType string `json:"nodeType"`
	}{}
	if err := c.Bind(&req); err != nil {
		log.Println(fmt.Errorf("参数解析异常,%v", err))
		c.JSON(models.FailData(err.Error()))
		return
	}
	if excel.IsConflict(req.NodeType) {
		c.JSON(models.Fail(common.ErrorConflict, "冲突未解决：nodeType="+req.NodeType))
		return
	}
	excel.ExcelToDB(req.NodeType, true)
	c.JSON(models.Ok())
}
